package com.jkgh.remedium;

import com.jkgh.asin.StateMachine;
import com.jkgh.remedium.objects.messages.RemediumOutMessage;
import com.jkgh.remedium.states.OrderAwaitingState;

public class RemediumServerClientConnection extends RemediumHost {

	private final StateMachine machine;
	private final RemediumServer server;
	private int hostID;

	public RemediumServerClientConnection(RemediumServer server, StateMachine machine) {
		this.server = server;
		this.machine = machine;
	}

	@Override
	public final StateMachine getMachine() {
		return machine;
	}

	public final void onAuthenticated() {
		server.onAuthenticated(this);
	}

	public final void awaitOrders() {
		machine.setCurrentState(new OrderAwaitingState(this));
	}

	public final void send(RemediumOutMessage message) {
		message.produce(machine);
	}

	public final RemediumServer getServer() {
		return server;
	}

	public void assignHostID(int assignedHostID) {
		this.hostID = assignedHostID;
	}

	public int getHostID() {
		return hostID;
	}

}
